import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
//import myqmlclass 1.0

Window {
    id: window
    visible: true
    width: 1700
    height: 630
    title: qsTr("Hello World")

    // 20221004 zd 增加信号
    signal testS(var t1, var t2) //信号

    function testR (r1, r2) {    //槽

            console.log("re:" + r1)
            console.log("re:" + r2)
        }

    Image {
        id: background
        anchors.fill: parent
        source: "image/background.jpg"
    }


    // 主页面一开始设置"隐藏"，登录成功后才显示
    MainPage {
           id: mainPage
           width: 1700
           height: 630
           visible: false // 设置"隐藏"
           anchors.centerIn: parent
       }

    // 图片选项界面
    ImageItem {
        id:imageitem
        //border.color: "red"
        width: 1700
        height: 630
        visible: false

    }

    ImageTest {
        id:win
        visible: false
    }

    // 登陆界面
    LoginPage {
           id: loginPage
           width: 1700
           height: 630
           anchors.centerIn: parent
           visible: false
       }

    /*
    MyQmlClass {
        id: myQmlImp
    }*/

    Label{
        id:label
        text:""

        anchors.bottom: button1.top
        anchors.left: button1.left
    }

    Button{
        id:button1
        text:"获取"
        width:120
        height: 40

        anchors.centerIn: parent
        onClicked: {
            label.text = myQmlImp.getValue()
            imageitem.visible = false
        }
    }

    TextField{
        id:textField
        width: button1.width
        height: button1.height

        anchors.top: button1.bottom
        anchors.topMargin: 10
        anchors.left: button1.left
    }

    Button{
            id: setBtn
            text: "设置"
            width: textField.width      //可以设置成getBtn.width或者120
            height: textField.height    //可以设置成getBtn.height或者40

            anchors.top: textField.bottom
            anchors.left: textField.left

            onClicked: {
                var value = textField.text
                myQmlImp.setValue(value)

                testS(10, 20);        //发射信号

                imageitem.visible = true
                //window.visible = false


            }

    }

    Button{
        text: "主页面-返回按钮"

        anchors.left: setBtn.right + 20
        anchors.bottom: button1.top

        onClicked: {
            loginPage.visible = true
        }
    }

    Component.onCompleted: {     //建立连接
            testS.connect(testR)     //信号与槽的连接方式一（方式二请看文首链接）
    }

}
